package com.heima.article.controller.v1;

import com.heima.article.service.ApAuthorService;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/author")
@Api(value = "文章服务管理",tags = "自媒体作者信息")
public class ApAuthorController {

    @Autowired
    ApAuthorService apAuthorService;

    /*
    * 根据id查询作者信息
    * */
    @ApiOperation("自媒体作者信息查询")
    @GetMapping("/findByUserId/{id}")
    public ResponseResult<ApAuthor> findByUserId(@PathVariable("id") Integer userId){
        return apAuthorService.findByUserId(userId);
    }

    //作者信息保存
    /*
     * 根据id查询作者信息
     * */
    @ApiOperation("自媒体作者信息保存")
    @PostMapping("/save")
    public ResponseResult<ApAuthor> save(@RequestBody ApAuthor apAuthor){
        return apAuthorService.saveApAuthor(apAuthor);
    }
}
